<?php
/**
 * ============================================================================
 * 版权所有 2008-2011 多多网络，并保留所有权利。
 * 网站地址: http://soft.duoduo123.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
session_start();
error_reporting(0);
include_once 'comm/config.php';
include 'comm/class_db.php';
include_once 'comm/checkpostandget.php';
include_once 'comm/page.class.php';
$shai_set=include 'data/shai.php';
$shaicat_arr=$shai_set['shai_cat'];
$userid=intval($_GET['id'])?intval($_GET['id']):0;
if($userid==0){
    header('Location:baobeilist.php');
}
$catid=intval($_GET['catid']);
$xs=$_GET['xs']?$_GET['xs']:'all';
$page = !($_GET['page'])?'1':intval($_GET['page']);
$pagesize=24;
$page2=($page-1)*$pagesize;

if($catid>0 and $xs=='all') $where="where dduserid='".$userid."' and catid='".$catid."'";
elseif($catid<=0 and $xs=='all') $where="where dduserid='".$userid."'";
elseif($catid>0 and $xs=='like') $where="where a.id=b.shai_id and catid='$catid' and b.dduserid='".$userid."'";
elseif($catid<=0 and $xs=='like') $where="where a.id=b.shai_id and b.dduserid='".$userid."'";

$sql="select ddusername,hart from ".$BIAOTOU."user where Id='".$userid."' limit 1";
$query=mysql_query($sql);
if($query==''){
    header('Location:baobeilist.php');
}
$info=mysql_fetch_array($query);

$sql="select id from ".$BIAOTOU."shai where xs='shai' and dduserid='".$userid."'"; //晒单宝贝数量
$query=mysql_query($sql);
$shai_nums=mysql_num_rows($query);
$shai_nums=$shai_nums?$shai_nums:0;

$sql="select id from ".$BIAOTOU."shai where xs='share' and dduserid='".$userid."'"; //分享宝贝数量
$query=mysql_query($sql);
$share_nums=mysql_num_rows($query);
$share_nums=$share_nums?$share_nums:0;
$i=0;
if($xs=='all'){
	$sql="select `id`,`title`,`ddusername`,`image`,`hart`,`hits`,`comment`,`dduserid`,time from ".$BIAOTOU."shai $where";
    $query=mysql_query($sql);
	$total=mysql_num_rows($query);
    $sql="select `id`,`title`,`ddusername`,`image`,`hart`,`hits`,`comment`,`dduserid`,time from ".$BIAOTOU."shai $where order by id desc limit $page2,$pagesize";
    $query=mysql_query($sql);
    while($row=mysql_fetch_array($query)){
        $shaidan_arr[$i]=$row;
	    $shaidan_arr[$i]['comment']=preg_replace('/{(.*?)}/','',$row['comment']);
	    $i++;
    }
}
else{
	$sql="select a.`ddusername`,a.`title`,a.`image`,a.`hart`,a.`hits`,a.`comment`,a.`dduserid`,a.time,b.shai_id as id from ".$BIAOTOU."shai as a,".$BIAOTOU."shai_hart as b $where order by id desc";
    $query=mysql_query($sql);
	$total=mysql_num_rows($query);
    $sql="select a.`ddusername`,a.`title`,a.`image`,a.`hart`,a.`hits`,a.`comment`,a.`dduserid`,a.time,b.shai_id as id from ".$BIAOTOU."shai as a,".$BIAOTOU."shai_hart as b $where order by b.id desc limit $page2,$pagesize";
    $query=mysql_query($sql);
    while($row=mysql_fetch_array($query)){
        $shaidan_arr[$i]=$row;
	    $shaidan_arr[$i]['comment']=preg_replace('/{(.*?)}/','',$row['comment']);
	    $i++;
    }
}

$tag='shai';
$pagetag='userbaobei';
include_once 'comm/wjt.php';
include_once 'comm/seo.php';
//引入模版文件
include 'template/'.MOBAN.'/userbaobei.tpl.php';
mysql_close();
?>